package main

import "sort"

func main() {

}

func getSkyline(buildings [][]int) [][]int {
	result := make([][]int, 0)
	tempMap := make(map[int]int)
	xArray := make([]int, 0)
	for _, building := range buildings {
		tempMap[building[0]] = building[2]
		tempMap[building[1]] = building[2]
		xArray = append(xArray, building[0])
		xArray = append(xArray, building[1])
	}
	sort.Ints(xArray)
	result = append(result, []int{xArray[len(xArray)-1], 0})
	preHeight := 0
	for i := len(xArray) - 2; i >= 0; i-- {
		if h := tempMap[xArray[i]]; h != preHeight {
			result = append(result, []int{xArray[i], h})
			preHeight = h
		}
	}
	for i := 0; i < len(result); i++ {
		result[i], result[len(result)-i-1] = result[len(result)-i-1], result[i]
	}
	return result
}
